<template>
  <div>
    <table>
      <tr>
        <td>编号</td>
        <td>图书</td>
        <td>作者</td>
      </tr>
      <tr v-for="item in books">
        <td>{{item.id}}</td>
        <td>{{item.name}}</td>
        <td>{{item.author}}</td>
      </tr>
    </table>
  </div>
</template>

<script>
  export default {
    data(){
      return{
        books: [
          {
            id: 1,
            name: '解忧杂货店',
            author: '东野圭吾'
          },{
            id: 2,
            name: '追风筝的人',
            author: '卡勒德·胡赛尼'
          },{
            id: 3,
            name: '人间失格',
            author: '太宰治'
          }
        ]
      }
    },
    created() {
      const _this = this
      this.$axios.get('http://localhost:8181/book/findAll' ).then((resp) => {
        this.books = resp.data
        //console.log(resp)
      })
    }
  }
</script>
